import './assets/main.css'

import { createApp } from 'vue'
import { createMemoryHistory, createRouter } from 'vue-router'
import App from './App.vue'
import HomeView from '@/pages/domain.vue'
import LoginView from '@/pages/dologin.vue'
import pagePosList from '@/pages/pagePosList.vue';
import pageIndex from './pages/pageIndex.vue'

import subNavbar from './components/subNavbar.vue'
import trPosInfo from './components/trPosInfo.vue'
import trHeader from './components/trHeader.vue'

import 'bootstrap'
import 'bootstrap/dist/css/bootstrap.css'
import 'mdi/css/materialdesignicons.min.css'
import 'base'

import axios from 'axios';
const routes = [
    { path: '/', component: LoginView },
    {
        path: '/home', component: HomeView, children: [
            { path: '/pagePosList', component: pagePosList },
            { path: '/pageIndex', component: pageIndex }
        ]
    }
]

const router = createRouter({
    history: createMemoryHistory(),
    routes
})

const www = axios.create({
    baseURL: 'http://192.168.1.218:8300',
    timeout: 5000,
    headers: { 'Content-Type': 'application/json' }
})
// 在实例已创建后修改默认值
// www.defaults.headers.common['Authorization'] = AUTH_TOKEN;

const app = createApp(App)

app.config.globalProperties.$globalVar = {   // 全局变量
    host: 'http://192.168.1.218:8300',
    token: localStorage.getItem('token') || null,
    user: localStorage.getItem('user') || null,
    info: localStorage.getItem('info') || null,
    login: localStorage.getItem('login') || null,
}

app.component('subNavbar', subNavbar)
app.component('trPosInfo', trPosInfo)
app.component('trHeader', trHeader)
app.config.globalProperties.axios = www
app.use(router)

app.mount('#app')

// npm config set registry https://registry.npmmirror.com